clear all; close all;

samples = Samples('E1',...
									'/home/ondrej/wnav/snapshots/snapshot_mem_02_e1.dat');
E1c_sc = SecondaryPRNCode('E1c');
NumberOfSamples = floor(E1c_sc.ChipPeriod/samples.SamplingPeriod);
NumberOfPeriods = 1;
E1b_pc = PrimaryPRNCode('E1b', NumberOfSamples, 1); 
E1c_pc = PrimaryPRNCode('E1c', NumberOfSamples, 1); 
samples.loadSamples(NumberOfSamples*(NumberOfPeriods+1));
acq = Acquisition('E1', samples.FrequencyOffset);
for SVID = 1:50
	fprintf(1, 'Acquiring E1 PRN %d ... \n', SVID);
	acq.Acquire(samples, NumberOfPeriods, 1e-5, SVID, E1b_pc, E1c_pc);
	if (acq.DetectionStatus)
		fprintf(1, 'E1 PRN %d successfully acquired! \n', SVID);
		figure(SVID); clf;
		[m n] = size(acq.CCF);
		plot((1:m)*samples.SamplingPeriod, abs(acq.CCF),...
				 (1:m)*samples.SamplingPeriod, repmat(acq.Threshold, m, 1));
		xlabel('Time [s]');
		ylabel('CorrOut [-]');
		legend('CCF','Threshold');
	end
end

